import 'package:flutter/material.dart';
import 'package:wan_android/pages/home_page/home_page.dart';
import 'package:wan_android/pages/mine_page/mine_page.dart';
import 'package:wan_android/pages/project_page/project_page.dart';
import 'package:wan_android/pages/system_page/system_page.dart';

class IndexPage extends StatefulWidget {
  const IndexPage({super.key});

  @override
  State<IndexPage> createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: BottomNavigationBar(
        selectedItemColor: Colors.blueAccent,
        currentIndex: _currentIndex,
        type: BottomNavigationBarType.fixed,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
          BottomNavigationBarItem(icon: Icon(Icons.list), label: '项目'),
          BottomNavigationBarItem(icon: Icon(Icons.video_call), label: '视频'),
          BottomNavigationBarItem(icon: Icon(Icons.person), label: '我的'),
        ],
      ),

      body: IndexedStack(
        index: _currentIndex,
        children: const [
          HomePage(),
          ProjectPage(),
          SystemPage(),
          MinePage()
        ],
      ),
    );
  }
}
